cd $path
echo "
This script is designed to simplify the process of Freesurfer. 

1- In the first instance, script will ask you to select the process type; (mri_convert), (recon-all process), (view volume or surface), (fteeview) (Quality Assurance) or (QDEC).

2- If you select (recon-all process), you will be given a choice of the recon-all stages and script will ask you to choose the subjects' directory. Then it will ask you to select subject's ID.

3- If you select (view volume or surface) then script will ask you to choose type of image that you want to view; volume or surface. Then it will ask the subject's folder and the file name.

4- If you want to use freeview application just write down freeview.

5- If you want to use QDEC application performing inter-subject/group averaging and inference on the morphometry data (cortical surface and volume) produced by the FreeSurfer processing stream.
"
echo "Written by Jamaan Alghamdi & Dr. Vanessa Sluming"
echo "University of Liverpool"
echo "jamaan.alghamdi@gmail.com"
echo "http://www.easyneuroimaging.com"
echo "03/06/2012

"

export FREESURFER_HOME=/Applications/freesurfer
sleep 1
source $FREESURFER_HOME/SetUpFreeSurfer.sh
sleep 1

export SUBJECTS_DIR=$PWD

echo "Write down process type 
## select one of the following process ##
 			 recon-all
			 view_volume
			 view_surface
			 freeview
			 QDEC
"
read Process_type

if [ "$Process_type" = recon-all ]; then

echo "
Write down stage type 
## select one of the following options ##
 	   		 -all
			 -autorecon1
			 -autorecon2
			 -autorecon2-cp
			 -autorecon2-wm
			 -autorecon2-pial
			 -autorecon3
			 -qcache
			 -hippo-subfields
			 -all -hippo-subfields
"

read stage
echo "
Write down subjects' IDs selecting from the following list 
## Leave spaces between IDs ## like C01 C02 C03 
"
ls -d */

read IDs

for i in $IDs;
do
recon-all -s $i $stage ; done

elif [ "$Process_type" = view_volume ]; then

echo "
Write down subject's ID selecting from the following list 
## like C01 ## 
"
ls -d */

read ID

echo "
Write down volume name 
for example you can write ##  orig.mgz ## 
			orig.mgz
			T1.mgz
			nu.mgz
			brainmask.mgz
			norm.mgz
			aseg.mgz
			filled.mgz
"
read volume_name
tkmedit $ID $volume_name

elif [ "$Process_type" = view_surface ]; then

echo "
Write down subject's ID selecting from the following list 
for example you can write ##  C01 ## 
"
ls -d */

read ID

echo "
Write down hemisphere 
## lh or rh ## 
"
read hemi

echo "
Write down volume name 
for example you can write ##  pial ## 
			pial
			inflated
			white
"
read surface_name

tksurfer $ID $hemi $surface_name


elif [ "$Process_type" = freeview ]; then
freeview $i


elif [ "$Process_type" = QDEC ]; then

QDEC

fi